#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sqlalchemy import String

from sqlalchemy.orm import Mapped, mapped_column

from backend.app.core.models.base import Base, id_key


class Tunnel(Base):
    """系统api"""

    __tablename__ = 'dbms_tunnel'

    id: Mapped[id_key] = mapped_column(init=False)
    tunnel_name: Mapped[str] = mapped_column(String(50), unique=True, comment='tag名称')
    host: Mapped[str] = mapped_column(String(50), unique=True, comment='tag代码')
    port: Mapped[int] = mapped_column(default=3306, comment='角色状态（3306 mysql 1 6379 redis 9200 es 1433 sql）')
    user: Mapped[str] = mapped_column(String(50), unique=True, comment='tag代码')
    password: Mapped[str] = mapped_column(String(50), unique=True, comment='tag代码')
    pkey: Mapped[str] = mapped_column(String(50), unique=True, comment='tag代码')
    pkey_password: Mapped[str] = mapped_column(String(50), unique=True, comment='tag代码')
    status: Mapped[int] = mapped_column(default=1, comment='角色状态（0停用 1正常）')
    remark: Mapped[str | None] = mapped_column(String(255), comment='备注')
    instances: Mapped[Union['Instance', None]]= relationship(init=False, back_populates='tunnel')
